package com.lanou.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lanou.bean.Rosi;
import com.lanou.mapper.RosiMapper;
import com.lanou.service.RosiService;
import com.lanou.utils.AjaxResult;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by dllo on 18/3/12.
 */
@Service
public class RosiServiceImpl implements RosiService{

    @Resource private RosiMapper rosiMapper;

    /**
     * zfy
     * 实现点击相关组图 显示出该组组图的所有信息
     * @param rosiId
     * @return
     */
    @Override
    public AjaxResult getAllMessageByRosiId(Integer rosiId) {
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.setData(rosiMapper.getAllMessageByRosiId(rosiId));
        ajaxResult.setCode("200");
        ajaxResult.setMsg("显示组图信息");
        return ajaxResult;
    }

    /**
     * zfy
     * 作用页面：效果图页面
     * 分页显示所有精品套图
     * @param pageNo 当前页
     * @param pageSize 每页显示条数
     * @return
     */
    @Override
    public PageInfo<Rosi> pageInfo(Integer pageNo, Integer pageSize) {
        pageNo = pageNo ==null ? 1 : pageNo;

        pageSize = pageSize == null ? 1 : pageSize;



        PageHelper.startPage(pageNo,pageSize);

        List<Rosi> rosiList = rosiMapper.getAllMessage();

        PageInfo<Rosi> pageInfo = new PageInfo<Rosi>(rosiList);

        return pageInfo;
    }

    @Override
    public AjaxResult getFourImg() {
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.setCode("200");
        ajaxResult.setMsg("获取四组图信息");
        ajaxResult.setData(rosiMapper.getFourMessage());
        return ajaxResult;
    }
}
